/*
Copyright To change this template, choose Tools | Templates
Copyright and open the template in the editor.
 */
package com.click.app.model;

import java.util.Date;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 * @author Joel Chuca Condo
 * @date 07/04/2009
 */

@Entity
@Table(name="purchase_payments")
public class PurchasePayment extends BaseObject {

    private Long id;
    private Purchase purchase;
    private Float amount;
    private Date date;
    private String code;
    private Float amountLeft;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name="id_purchase_payment", unique=true, nullable=false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="id_purchase")
    public Purchase getPurchase() {
        return this.purchase;
    }

    public void setPurchase(Purchase purchase) {
        this.purchase = purchase;
    }

    @Column(name="amount", precision=12, scale=0)
    public Float getAmount() {
        return this.amount;
    }

    public void setAmount(Float amount) {
        this.amount = amount;
    }
    @Temporal(TemporalType.DATE)
    @Column(name="date", length=10)
    public Date getDate() {
        return this.date;
    }

    public void setDate(Date date) {
        this.date = date;
    }


    public void setCode(String code) {
        this.code = code;
    }

    @Column(name="code", length=50)
    public String getCode() {
        return code;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PurchasePayment)) {
            return false;
        }
        PurchasePayment other = (PurchasePayment) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sodes.app.model.ReceiptPayment[id=" + id + "]";
    }
    @Column(name="amount_left", precision=12, scale=0)
    public Float getAmountLeft(){
        return this.amountLeft;
    }

    /**
     * @param amountLeft the amountLeft to set
     */
    public void setAmountLeft(Float amountLeft) {
        this.amountLeft = amountLeft;
    }
}
